1. Field of the Invention
This invention relates to generating electric signals, and more particularly to generating a square wave signal of any given period and duty cycle using an interval timer.
2. Description of Related Art
Interval timers are widely used in computer systems where some operations must be performed at precise intervals of time. Examples of such operations include updating a screen display or checking the state of a disk drive. The V25.TM. and V35.TM. type microprocessors are provided with timers that can be programmed as interval timers. The V25 microprocessor is described in .mu.PD70320/322 (V25.TM.) 16-Bit, Single-Chip CMOS Microcomputers (NEC Electronics, Inc. 1988; DOC. NO. UIC-UP50002A). The V35 microprocessor is described in .mu.PD70330/322 (V35.TM.) Advanced 16-Bit, Single-Chip CMOS Microcomputers (NEC Electronics, Inc. 1988; DOC. NO. JIC-UP50006). Both publications, as well as the microprocessors, are available from NEC Electronics Inc. in Mountain View, Calif.
FIG. 1 shows a block diagram of the V25 microprocessor 1. Microprocessor 1 includes a 16-bit timer unit 100. Bus 38 connects timer unit 100 to other parts of microprocessor 1.
Timer unit 100 is shown in detail in FIG. 2. Timer unit 100 contains two timers--timer 58 and timer 68. Timer 68 contains a count register TM0 (reference numeral 64) and a modulus register MD0 (reference numeral 62). Timer 68 can be programmed in an interval timer mode. In this mode, TM0 register 64 and MD0 register 62 are initialized to certain values by microprocessor 1. TM0 register 64 is decremented by 1 on every cycle of an input clock. When TM0 register 64 counts down to 0, flag TF0 is set. This causes the value of MD0 register 62 to be loaded into TM0 register 64. Then TM0 register 64 resumes counting down. Thus TM0 register 64 counts from the value of MD0 register 62 down to 0 repeatedly until timer 68 is reprogrammed. TM0 register 64 reaches 0 at regular intervals of time.
Timer 68 is used to generate interrupts at regular intervals of time. Each time TM0 register 64 counts down to 0 and TF0 flag 67 gets set, an interrupt is requested.
Timer 68 is used to generate square waves such as the square wave of FIG. 3. TF0 flag 67 is connected to an external output pin TOUT (reference numeral 30) of microprocessor 1 through output control 69. Microprocessor 1 generates a timer-out signal on TOUT pin 30. Each time TF0 flag 30 is set, the timer-out signal is toggled by output control 69. When timer 68 operates in the interval timer mode, the timer-out signal is a square wave with half-cycle equal to the time it takes TM0 register 64 to count from the value of MD0 register 62 to 0.
Timer unit 100 contains timer 58 which has a modulus register MD1 (reference numeral 52) and a count register TM1 (reference numeral 54). Timer 58 is also used to generate interrupts at regular intervals of time. Timer 58, however, is not connected to TOUT pin 30.